TARGET = lynxi_mcu

# Source dir
ST_HAL_DRIVER_SRC_DIR := Drivers/STM32G0xx_HAL_Driver/Src
ST_HAL_DIRVER_INC_DIR := Drivers/STM32G0xx_HAL_Driver/Inc

CORE_SRC_DIR := Core/Src
CORE_INC_DIR := Core/Inc

HAL_SOURCES = $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_i2c.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_i2c_ex.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_rcc.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_rcc_ex.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_ll_rcc.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_flash.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_flash_ex.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_gpio.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_dma.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_dma_ex.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_ll_dma.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_pwr.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_pwr_ex.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_cortex.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_exti.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_iwdg.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_spi.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_spi_ex.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_tim.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_tim_ex.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_uart.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_uart_ex.c
HAL_SOURCES += $(ST_HAL_DRIVER_SRC_DIR)/stm32g0xx_hal_wwdg.c

C_SOURCES += $(HAL_SOURCES)
C_SOURCES += $(CORE_SRC_DIR)/main.c
C_SOURCES += $(CORE_SRC_DIR)/stm32g0xx_it.c
C_SOURCES += $(CORE_SRC_DIR)/stm32g0xx_hal_msp.c
C_SOURCES += $(CORE_SRC_DIR)/system_stm32g0xx.c

ifeq ($(CONFIG_LYNXI_MCU_CMD_LINE), y)
C_SOURCES += $(CORE_SRC_DIR)/cmd.c
C_SOURCES += $(CORE_SRC_DIR)/cmd_help.c
C_SOURCES += $(CORE_SRC_DIR)/cmd_pwr.c
endif

C_SOURCES += $(CORE_SRC_DIR)/crc32.c
C_SOURCES += $(CORE_SRC_DIR)/flash_if.c
C_SOURCES += $(CORE_SRC_DIR)/gpio.c
C_SOURCES += $(CORE_SRC_DIR)/i2c_app.c
C_SOURCES += $(CORE_SRC_DIR)/i2c.c
C_SOURCES += $(CORE_SRC_DIR)/iwdg.c
C_SOURCES += $(CORE_SRC_DIR)/log.c
C_SOURCES += $(CORE_SRC_DIR)/power.c
C_SOURCES += $(CORE_SRC_DIR)/spi.c
C_SOURCES += $(CORE_SRC_DIR)/task.c
C_SOURCES += $(CORE_SRC_DIR)/tim.c
C_SOURCES += $(CORE_SRC_DIR)/uart_to_soc.c
C_SOURCES += $(CORE_SRC_DIR)/upgrade.c
C_SOURCES += $(CORE_SRC_DIR)/usart.c
C_SOURCES += $(CORE_SRC_DIR)/wwdg.c

# ASM sources
ASM_SOURCES =  \
startup/startup_stm32g030xx.s


# like ld script
ifeq ($(CONFIG_LYNXI_MCU_CMD_LINE), y)
SCATTER_FILE = sct/lynxi_mcu_cmd.sct
else ifeq ($(CONFIG_LYNXI_MCU_IAP_UPGRADE), y)
SCATTER_FILE = sct/lynxi_mcu_iap.sct
else
SCATTER_FILE = sct/lynxi_mcu.sct
endif

BUILD_DIR = build_app
